<?php
require_once 'test-00-inc.php';

start('Element value (text) manipulations');

test('Text node is accessible if
    it is the only child:','
    $para = $html->body->p[1],
    (string)$para[0],
    $para[0] = "It is changed!"
');

test('Text node IS NOT accessible if
    it IS NOT the only child:','
    $test = $html->body->p[0],
    (string)$test
');
foreach (nz($test) as $key => $item) {
    echo $key, " => "; var_dump($item);
}

test('Text nodes IS NOT accessible by selection
    (SXMLE::xpath() returns elements instead of text nodes):','
    $html->body->select("p[1]/text()")->items
');

test('Text value is accessible by typecasting to (string)
    or by calling value() method','
    (string)$html->body->p[0],
    $html->body->p[1]->value()
');

result($html);